home *** CD-ROM | disk | FTP | other *** search
/ Czech Logic, Card & Gambling Games / Logické hry.iso / hry / Fish Fillets / script / barrel / code.lua next >
Encoding:
Text File  |  2005-07-16  |  33.0 KB  |  933 lines

  1.  
  2. file_include('script/share/prog_border.lua')
  3.  
  4. -- -----------------------------------------------------------------
  5. -- Init
  6. -- -----------------------------------------------------------------
  7. local function prog_init()
  8.     initModels()
  9.     sound_playMusic("music/rybky05.ogg")
  10.     local pokus = getRestartCount()
  11.  
  12.     --NOTE: a final level
  13.     small:setGoal("goal_alive")
  14.     big:setGoal("goal_alive")
  15.     barel:setGoal("goal_out")
  16.  
  17.     -- -------------------------------------------------------------
  18.     local function prog_init_room()
  19.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  20.  
  21.         room.uvod = 0
  22.         room.celakrajni = 0
  23.         room.ozviratkach = {}
  24.         room.hl1 = random(400) + 400
  25.         room.hl2 = room.hl1 + random(800) + 800
  26.         room.hl3 = room.hl2 + random(1600) + 1600
  27.         room.hl4 = room.hl3 + random(3200) + 3200
  28.         room.onoze = 0
  29.         room.opldech = 0
  30.         room.okukajde = 0
  31.         room.okrabovi = 0
  32.         room.okachne = 0
  33.  
  34.         return function()
  35.             if stdBorderReport() then
  36.                 addm(6, "bar-m-barel")
  37.                 if random(100) < 30 or room.celakrajni == 0 then
  38.                     addv(random(10) + 5, "bar-v-genofond")
  39.                 end
  40.                 room.celakrajni = 1
  41.             end
  42.             if no_dialog() and isReady(small) and isReady(big) then
  43.                 if room.hl1 > 0 then
  44.                     room.hl1 = room.hl1 - 1
  45.                 end
  46.                 if room.hl2 > 0 then
  47.                     room.hl2 = room.hl2 - 1
  48.                 end
  49.                 if room.hl3 > 0 then
  50.                     room.hl3 = room.hl3 - 1
  51.                 end
  52.                 if room.hl4 > 0 then
  53.                     room.hl4 = room.hl4 - 1
  54.                 end
  55.                 if room.uvod == 0 then
  56.                     room.uvod = 1
  57.                     switch(pokus){
  58.                         [1] = function()
  59.                             pom1 = 5
  60.                         end,
  61.                         [2] = function()
  62.                             pom1 = randint(2, 4)
  63.                         end,
  64.                         default = function()
  65.                             pom1 = random(6)
  66.                         end,
  67.                     }
  68.                     adddel(10 + random(20))
  69.                     if pom1 >= 4 then
  70.                         switch(random(2)){
  71.                             [0] = function()
  72.                                 addv(0, "bar-v-videt0")
  73.                             end,
  74.                             [1] = function()
  75.                                 addm(0, "bar-m-videt1")
  76.                             end,
  77.                         }
  78.                     end
  79.                     if pom1 >= 5 then
  80.                         addv(5, "bar-v-co")
  81.                     end
  82.                     if pom1 >= 2 then
  83.                         addm(10, "bar-m-pobit")
  84.                         planDialogSet(2, "bar-x-suckne", 201, pldik, "cinnost")
  85.                         addv(10, "bar-v-priciny")
  86.                         planDialogSet(2, "bar-x-suckano", 202, pldik, "cinnost")
  87.                     end
  88.                     if pom1 >= 4 then
  89.                         addm(random(30) + 10, "bar-m-no")
  90.                     end
  91.                     if pom1 >= 2 then
  92.                         addv(5, "bar-v-sud")
  93.                     end
  94.                     if pom1 >= 3 then
  95.                         addm(5, "bar-m-panb")
  96.                     end
  97.                 elseif room.hl1 == 0 or room.hl2 == 0 or room.hl3 == 0 or room.hl4 == 0 then
  98.                     if room.hl1 == 0 then
  99.                         room.hl1 = -1
  100.                     end
  101.                     if room.hl2 == 0 then
  102.                         room.hl2 = -1
  103.                     end
  104.                     if room.hl3 == 0 then
  105.                         room.hl3 = -1
  106.                     end
  107.                     if room.hl4 == 0 then
  108.                         room.hl4 = -1
  109.                     end
  110.                     if countPairs(room.ozviratkach) == 0 then
  111.                         pom1 = random(2)
  112.                     elseif countPairs(room.ozviratkach) == 4 then
  113.                         room.ozviratkach = {}
  114.                         pom1 = random(4)
  115.                     else
  116.                         repeat
  117.                             pom1 = random(4)
  118.                         until not room.ozviratkach[pom1]
  119.                     end
  120.                     room.ozviratkach[pom1] = true
  121.                     adddel(50 + random(100))
  122.                     switch(pom1){
  123.                         [0] = function()
  124.                             addm(0, "bar-m-rada")
  125.                             addv(7, "bar-v-kdyby" ..random(2))
  126.                         end,
  127.                         [1] = function()
  128.                             addm(0, "bar-m-mutanti")
  129.                             if random(100) < 50 then
  130.                                 addv(10, "bar-v-ufouni")
  131.                             end
  132.                             addm(random(50) + 10, "bar-m-zmeni")
  133.                         end,
  134.                         [2] = function()
  135.                             addv(0, "bar-v-lih")
  136.                             addm(8, "bar-m-fdto")
  137.                             pldotec:planDialog(3, "bar-x-vypr")
  138.                             addm(10, "bar-m-promin")
  139.                         end,
  140.                         [3] = function()
  141.                             addv(0, "bar-v-sbirka")
  142.                             addm(10, "bar-m-dost" ..random(2))
  143.                         end,
  144.                     }
  145.                 elseif room.onoze == 0 and nozka.cinnost < 20 and dist(small, nozka) < 5 and random(1000) < 2 then
  146.                     room.onoze = 1
  147.                     addm(3, "bar-m-noha")
  148.                 elseif room.opldech == 0 and dist(big, pldotec) <= 5 and random(100) < 1 then
  149.                     room.opldech = 1
  150.                     addv(10, "bar-v-pld")
  151.                     addm(6, "bar-m-pudy")
  152.                     addv(2, "bar-v-traverza")
  153.                     planDialogSet(2, "bar-x-suckne", 201, pldik, "cinnost")
  154.                 elseif room.okukajde == 0 and kukajda.dir ~= dir_no and random(100) < 2 and small.dir ~= dir_no then
  155.                     room.okukajde = 1
  156.                     addm(10, "bar-m-rybka")
  157.                     if random(100) < 70 then
  158.                         addv(random(30) + 5, "bar-v-fotka")
  159.                     end
  160.                 elseif room.okrabovi == 0 and look_at(big, krabik) and dist(big, krabik) <= 3 and random(100) < 1 then
  161.                     room.okrabovi = 1
  162.                     addv(10, "bar-v-krab")
  163.                 elseif room.okachne == 0 and kachnicka.dir ~= dir_no and small.dir ~= dir_no and random(100) < 10 then
  164.                     room.okachne = 1
  165.                     addm(5, "bar-m-kachna")
  166.                 end
  167.             end
  168.         end
  169.     end
  170.  
  171.     -- -------------------------------------------------------------
  172.     local function prog_init_barel()
  173.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  174.  
  175.         setanim(barel, "a0d8a1a2a3a4d3a3a2a1R")
  176.  
  177.         return function()
  178.             goanim(barel)
  179.             barel:updateAnim()
  180.         end
  181.     end
  182.  
  183.     -- -------------------------------------------------------------
  184.     local function prog_init_kachnicka()
  185.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  186.  
  187.         kachnicka.cinnost = random(100) + 10
  188.  
  189.         return function()
  190.             if kachnicka.cinnost > 0 then
  191.                 if kachnicka:isTalking() then
  192.                     kachnicka:killSound()
  193.                 end
  194.                 if odd(game_getCycles()) and random(100) < 10 then
  195.                     kachnicka.afaze = random(5)
  196.                 end
  197.                 kachnicka.cinnost = kachnicka.cinnost - 1
  198.                 if kachnicka.cinnost == 0 then
  199.                     kachnicka.afaze = 5
  200.                     kachnicka.cinnost = -30 - random(60)
  201.                 end
  202.             else
  203.                 if not kachnicka:isTalking() then
  204.                     kachnicka:talk("bar-x-kchkch", VOLUME_LOW, -1)
  205.                 end
  206.                 kachnicka.afaze = math.mod(kachnicka.afaze - 5 + 1, 4) + 5
  207.                 kachnicka.cinnost = kachnicka.cinnost + 1
  208.                 if kachnicka.cinnost == 0 then
  209.                     kachnicka.afaze = 0
  210.                     kachnicka.cinnost = 30 + random(100)
  211.                 end
  212.             end
  213.             kachnicka:updateAnim()
  214.         end
  215.     end
  216.  
  217.     -- -------------------------------------------------------------
  218.     local function prog_init_had()
  219.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  220.  
  221.         had.streva = random(4)
  222.         had.huba = random(3)
  223.  
  224.         return function()
  225.             if math.mod(game_getCycles(), 3) == 0 then
  226.                 if (had.huba == 0) then
  227.                         if random(1000) < 15 then
  228.                             had.huba = random(2) + 1
  229.                         end
  230.                 else
  231.                         if random(1000) < 15 then
  232.                             had.huba = 0
  233.                         elseif random(100) < 50 then
  234.                             had.huba = 3 - had.huba
  235.                         end
  236.                 end
  237.             end
  238.             had.streva = math.mod(had.streva + 1, 4)
  239.             had.afaze = 4 * had.huba + had.streva
  240.             had:updateAnim()
  241.         end
  242.     end
  243.  
  244.     -- -------------------------------------------------------------
  245.     local function prog_init_ocicko()
  246.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  247.  
  248.         ocicko.cinnost = 0
  249.  
  250.         return function()
  251.             if (ocicko.cinnost == 0) then
  252.                     local rnd = random(8)
  253.                     if random(100) < 10 then
  254.                         if (rnd >= 0) and (rnd <= 2) then
  255.                                 ocicko.citac = random(5) + 5
  256.                                 ocicko.cinnost = 1
  257.                                 ocicko.faze = random(2) * 2
  258.                         elseif (rnd == 3) then
  259.                                 ocicko.citac = random(3) + 2
  260.                                 ocicko.cinnost = 2
  261.                                 ocicko.faze = random(2) * 2
  262.                         elseif (rnd >= 4) and (rnd <= 6) then
  263.                                 ocicko.citac = random(12) + 12
  264.                                 ocicko.cinnost = 3 + random(2)
  265.                         elseif (rnd == 7) then
  266.                                 ocicko.citac = random(10) + 2
  267.                                 ocicko.cinnost = 5
  268.                         end
  269.                     end
  270.             elseif (ocicko.cinnost == 1) or (ocicko.cinnost == 2) then
  271.                     switch(ocicko.faze){
  272.                         [0] = function()
  273.                             if ocicko.cinnost == 1 then
  274.                                 ocicko.afaze = 1
  275.                             else
  276.                                 ocicko.afaze = 3
  277.                             end
  278.                             if random(100) < 20 then
  279.                                 ocicko.faze = ocicko.faze + 1
  280.                             end
  281.                         end,
  282.                         [1] = function()
  283.                             ocicko.afaze = 0
  284.                             ocicko.faze = ocicko.faze + 1
  285.                         end,
  286.                         [2] = function()
  287.                             if ocicko.cinnost == 1 then
  288.                                 ocicko.afaze = 2
  289.                             else
  290.                                 ocicko.afaze = 4
  291.                             end
  292.                             if random(100) < 20 then
  293.                                 ocicko.faze = ocicko.faze + 1
  294.                             end
  295.                         end,
  296.                         [3] = function()
  297.                             ocicko.afaze = 0
  298.                             ocicko.citac = ocicko.citac - 1
  299.                             if ocicko.citac == 0 then
  300.                                 ocicko.cinnost = 0
  301.                             else
  302.                                 ocicko.faze = 0
  303.                             end
  304.                         end,
  305.                     }
  306.                 elseif (ocicko.cinnost >= 3) or (ocicko.cinnost <= 5) then
  307.                     switch(ocicko.cinnost){
  308.                         [3] = function()
  309.                             switch(ocicko.afaze){
  310.                                 [0] = function()
  311.                                     ocicko.afaze = random(4) + 1
  312.                                 end,
  313.                                 [1] = function()
  314.                                     ocicko.afaze = 3
  315.                                 end,
  316.                                 [2] = function()
  317.                                     ocicko.afaze = 4
  318.                                 end,
  319.                                 [3] = function()
  320.                                     ocicko.afaze = 2
  321.                                 end,
  322.                                 [4] = function()
  323.                                     ocicko.afaze = 1
  324.                                 end,
  325.                             }
  326.                         end,
  327.                         [4] = function()
  328.                             switch(ocicko.afaze){
  329.                                 [0] = function()
  330.                                     ocicko.afaze = random(4) + 1
  331.                                 end,
  332.                                 [1] = function()
  333.                                     ocicko.afaze = 4
  334.                                 end,
  335.                                 [2] = function()
  336.                                     ocicko.afaze = 3
  337.                                 end,
  338.                                 [3] = function()
  339.                                     ocicko.afaze = 1
  340.                                 end,
  341.                                 [4] = function()
  342.                                     ocicko.afaze = 2
  343.                                 end,
  344.                             }
  345.                         end,
  346.                         [5] = function()
  347.                             if random(100) < 40 then
  348.                                 ocicko.afaze = random(5)
  349.                             end
  350.                         end,
  351.                     }
  352.                     ocicko.citac = ocicko.citac - 1
  353.                     if ocicko.citac == 0 then
  354.                         ocicko.cinnost = 0
  355.                         ocicko.afaze = 0
  356.                     end
  357.             end
  358.             ocicko:updateAnim()
  359.         end
  360.     end
  361.  
  362.     -- -------------------------------------------------------------
  363.     local function prog_init_kukajda()
  364.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  365.  
  366.         kukajda.ploutvicka = 0
  367.         kukajda.oci = 0
  368.         kukajda.mrknuti = 0
  369.  
  370.         return function()
  371.             kukajda.ploutvicka = math.mod(kukajda.ploutvicka + 1, 6)
  372.             if (kukajda.ploutvicka == 0) or (kukajda.ploutvicka == 1) then
  373.                     kukajda.afaze = 0
  374.             elseif (kukajda.ploutvicka == 2) or (kukajda.ploutvicka == 5) then
  375.                     kukajda.afaze = 1
  376.             elseif (kukajda.ploutvicka == 3) or (kukajda.ploutvicka == 4) then
  377.                     kukajda.afaze = 2
  378.             end
  379.  
  380.             if random(100) < 3 then
  381.                 kukajda.oci = random(5)
  382.             end
  383.             if kukajda.mrknuti > 0 then
  384.                 kukajda.mrknuti = kukajda.mrknuti - 1
  385.                 kukajda.afaze = kukajda.afaze + 15
  386.             else
  387.                 kukajda.afaze = kukajda.afaze + kukajda.oci * 3
  388.                 if random(100) < 4 then
  389.                     kukajda.mrknuti = random(3) + 2
  390.                 end
  391.             end
  392.             kukajda:updateAnim()
  393.         end
  394.     end
  395.  
  396.     -- -------------------------------------------------------------
  397.     local function prog_init_killer()
  398.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  399.  
  400.         killer.ocas = 0
  401.         killer.usmev = 0
  402.  
  403.         return function()
  404.             if odd(game_getCycles()) then
  405.                 killer.ocas = 1 - killer.ocas
  406.             end
  407.             if killer.usmev > 0 then
  408.                 killer.usmev = killer.usmev - 1
  409.                 killer.afaze = killer.ocas
  410.             else
  411.                 if random(100) < 2 then
  412.                     killer.usmev = random(30) + 10
  413.                     killer:talk("bar-x-gr" ..random(3), VOLUME_LOW)
  414.                 end
  415.                 killer.afaze = 2 * killer.ocas + 2
  416.                 if random(100) < 7 then
  417.                     killer.afaze = killer.afaze + 1
  418.                 end
  419.             end
  420.             killer:updateAnim()
  421.         end
  422.     end
  423.  
  424.     -- -------------------------------------------------------------
  425.     local function prog_init_hlubinna()
  426.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  427.  
  428.         hlubinna.ploutvicka = 0
  429.         hlubinna.zzzeni = 0
  430.  
  431.         return function()
  432.             hlubinna.ploutvicka = math.mod(hlubinna.ploutvicka + 1, 5)
  433.             if (hlubinna.ploutvicka == 3) then
  434.                     hlubinna.afaze = 1
  435.             elseif (hlubinna.ploutvicka == 4) then
  436.                     hlubinna.afaze = 0
  437.             else
  438.                     hlubinna.afaze = hlubinna.ploutvicka
  439.             end
  440.  
  441.             if hlubinna.zzzeni > 0 then
  442.                 hlubinna.afaze=hlubinna.afaze + 6
  443.                 hlubinna.zzzeni = hlubinna.zzzeni - 1
  444.             elseif random(100) < 5 then
  445.                 hlubinna.afaze = hlubinna.afaze + 3
  446.             elseif random(1000) < 15 then
  447.                 hlubinna.afaze=hlubinna.afaze + 6
  448.                 hlubinna.zzzeni = 5
  449.                 hlubinna:talk("bar-x-zzz", VOLUME_LOW)
  450.             end
  451.             hlubinna:updateAnim()
  452.         end
  453.     end
  454.  
  455.     -- -------------------------------------------------------------
  456.     local function prog_init_krabik()
  457.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  458.  
  459.         krabik.oci = 0
  460.  
  461.         return function()
  462.             if odd(game_getCycles()) and random(100) < 10 then
  463.                 krabik.oci = random(5)
  464.             end
  465.             if random(100) < 10 then
  466.                 krabik.afaze = 5
  467.             else
  468.                 krabik.afaze = krabik.oci
  469.             end
  470.             krabik:updateAnim()
  471.         end
  472.     end
  473.  
  474.     -- -------------------------------------------------------------
  475.     local function prog_init_baget()
  476.         return function()
  477.             if random(100) < 6 then
  478.                 baget.afaze = 1
  479.             else
  480.                 baget.afaze = 0
  481.             end
  482.             baget:updateAnim()
  483.         end
  484.     end
  485.  
  486.     -- -------------------------------------------------------------
  487.     local function prog_init_nozka()
  488.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  489.  
  490.         nozka.cinnost = random(100) + 20
  491.         nozka.dup = 0
  492.         nozka.oci = 0
  493.  
  494.         return function()
  495.             if odd(game_getCycles()) and random(100) < 10 then
  496.                 nozka.oci = random(5)
  497.             end
  498.             if nozka.cinnost > 0 then
  499.                 nozka.cinnost = nozka.cinnost - 1
  500.                 nozka.dup = 0
  501.                 if nozka.cinnost == 0 then
  502.                     nozka.cinnost = -20 - random(60)
  503.                 end
  504.             else
  505.                 if math.mod(game_getCycles(), 3) == 0 then
  506.                     nozka.dup = 1 - nozka.dup
  507.                     if nozka.dup == 0 then
  508.                         nozka:talk("bar-x-tup", VOLUME_LOW)
  509.                     end
  510.                 end
  511.                 if nozka.cinnost < -1 or nozka.dup == 0 then
  512.                     nozka.cinnost = nozka.cinnost + 1
  513.                 end
  514.                 if nozka.cinnost == 0 then
  515.                     nozka.cinnost = 10 + random(150)
  516.                 end
  517.             end
  518.             if random(100) < 4 then
  519.                 nozka.afaze = 5
  520.             else
  521.                 nozka.afaze = nozka.oci
  522.             end
  523.             nozka.afaze = nozka.afaze + nozka.dup * 6
  524.             nozka:updateAnim()
  525.         end
  526.     end
  527.  
  528.     -- -------------------------------------------------------------
  529.     local function prog_init_pldik()
  530.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  531.  
  532.         pldik.cinnost = 0
  533.         pldik.oci = 0
  534.         pldik.suckani = 0
  535.  
  536.         return function()
  537.             switch(pldik.cinnost){
  538.                 [0] = function()
  539.                     if random(1000) < 5 then
  540.                         pldik.cinnost = 1
  541.                     end
  542.                     if random(100) < 5 then
  543.                         pldik.oci = random(5)
  544.                         if pldik.oci > 0 then
  545.                             pldik.oci = pldik.oci + 1
  546.                         end
  547.                     end
  548.                     if pldik.suckani == 0 and random(100) < 4 then
  549.                         pldik.suckani = random(5) + 1
  550.                         pldik.suckfaze = 0
  551.                     end
  552.                 end,
  553.                 [1] = function()
  554.                     if random(1000) < 10 then
  555.                         pldik.cinnost = 0
  556.                     end
  557.                     pldik.oci = 6
  558.                     if pldik.suckani == 0 and random(100) < 4 then
  559.                         pldik.suckani = random(4) + 1
  560.                         pldik.suckfaze = 0
  561.                     end
  562.                 end,
  563.                 [201] = function()
  564.                     if not pldik:isTalking() then
  565.                         pldik.cinnost = 0
  566.                     end
  567.                     pldik.oci = 1
  568.                     if pldik.suckani == 0 then
  569.                         pldik.suckani = 1000
  570.                         pldik.suckfaze = 0
  571.                     end
  572.                 end,
  573.                 [202] = function()
  574.                     if not pldik:isTalking() then
  575.                         pldik.cinnost = 0
  576.                     end
  577.                     pldik.oci = 0
  578.                     if pldik.suckani == 0 then
  579.                         pldik.suckani = 1000
  580.                         pldik.suckfaze = 0
  581.                     end
  582.                 end,
  583.             }
  584.             pldik.afaze = pldik.oci * 2
  585.             if random(100) < 5 then
  586.                 pldik.afaze = 12
  587.             end
  588.             if pldik.suckani > 0 then
  589.                 if (pldik.suckfaze == 0) then
  590.                         if pldik.cinnost < 200 then
  591.                             pldik:talk("bar-x-suck" ..random(4), VOLUME_LOW)
  592.                         end
  593.                 elseif isRange(pldik.suckfaze, 1, 3) then
  594.                         pldik.afaze = pldik.afaze + 1
  595.                 elseif (pldik.suckfaze == 5) then
  596.                         pldik.suckani = pldik.suckani - 1
  597.                 end
  598.                 pldik.suckfaze = math.mod(pldik.suckfaze + 1, 6)
  599.             end
  600.             pldik:updateAnim()
  601.         end
  602.     end
  603.  
  604.     -- -------------------------------------------------------------
  605.     local function prog_init_shark()
  606.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  607.  
  608.         shark.oci = random(2)
  609.         shark.pusa = random(2)
  610.  
  611.         return function()
  612.             if random(1000) < 5 then
  613.                 shark.oci = 1 - shark.oci
  614.             end
  615.             if random(1000) < 5 then
  616.                 shark.pusa = 1 - shark.pusa
  617.             end
  618.             shark.afaze = shark.oci + shark.pusa * 2
  619.             if shark.oci == 0 and random(100) < 3 then
  620.                 shark.afaze = shark.afaze + 1
  621.             end
  622.             shark:updateAnim()
  623.         end
  624.     end
  625.  
  626.     -- -------------------------------------------------------------
  627.     local function prog_init_pldotec()
  628.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  629.  
  630.         pldotec.vlnit = 0
  631.         pldotec.del = 0
  632.         pldotec.ocko = 0
  633.         pldotec.smer = 0
  634.         pldotec.faze = 0
  635.         pldotec.smutny = 0
  636.  
  637.         return function()
  638.             switch(pldotec.dir){
  639.                 [dir_no] = function()
  640.                     if pldotec.vlnit == -1 then
  641.                         pldotec.vlnit = 8
  642.                     end
  643.                 end,
  644.                 [dir_down] = function()
  645.                     pldotec.vlnit = -1
  646.                 end,
  647.                 default = function()
  648.                     pldotec.vlnit = 8
  649.                 end,
  650.             }
  651.             if pldotec.vlnit > 0 then
  652.                 pldotec.smutny = 0
  653.             end
  654.             if pldotec.vlnit > 0 then
  655.                 if pldotec.del == 0 then
  656.                     if (pldotec.vlnit >= 6) and (pldotec.vlnit <= 8) then
  657.                             pldotec.del = 1
  658.                     elseif (pldotec.vlnit >= 3) and (pldotec.vlnit <= 5) then
  659.                             pldotec.del = 2
  660.                     else
  661.                             pldotec.del = 3
  662.                     end
  663.  
  664.                     if random(2) == 0 then
  665.                         pldotec.afaze = math.mod(pldotec.afaze + 1, 4)
  666.                     else
  667.                         pldotec.afaze = math.mod(pldotec.afaze + 3, 4)
  668.                     end
  669.                     pldotec.vlnit = pldotec.vlnit - 1
  670.                     if pldotec.vlnit == 0 then
  671.                         pldotec.del = 0
  672.                     end
  673.                     if pldotec.vlnit == 0 then
  674.                         pldotec.afaze = 0
  675.                     elseif pldotec.vlnit == 1 then
  676.                         pldotec.afaze = 3
  677.                     end
  678.                 else
  679.                     pldotec.del = pldotec.del - 1
  680.                 end
  681.             elseif pldotec.smutny > 0 then
  682.                 if pldotec.ocko == 0 then
  683.                     if random(100) < 10 then
  684.                         pldotec.ocko = 3
  685.                     end
  686.                 end
  687.                 if pldotec.ocko > 0 then
  688.                     pldotec.ocko = pldotec.ocko - 1
  689.                 end
  690.                 if pldotec.ocko > 0 then
  691.                     pldotec.afaze = 15
  692.                 else
  693.                     pldotec.afaze = 14
  694.                 end
  695.                 pldotec.smutny = pldotec.smutny - 1
  696.             else
  697.                 if random(100) < 10 then
  698.                     pldotec.smer = 1 - pldotec.smer
  699.                 end
  700.                 if (pldotec.faze == 0) then
  701.                         pldotec.afaze = 0
  702.                         if random(100) < 10 then
  703.                             pldotec.faze = 1
  704.                         end
  705.                 elseif (pldotec.faze == 1) or (pldotec.faze == 4) then
  706.                         pldotec.faze = pldotec.faze + 1
  707.                         pldotec.afaze = 4
  708.                 elseif (pldotec.faze == 5) then
  709.                         pldotec.afaze = 0
  710.                         pldotec.faze = 0
  711.                 else
  712.                         pldotec.faze = pldotec.faze + 1
  713.                         pldotec.afaze = 5
  714.                 end
  715.  
  716.                 switch(pldotec.afaze){
  717.                     [0] = function()
  718.                         if pldotec.smer == 1 then
  719.                             pldotec.afaze = 6
  720.                         end
  721.                     end,
  722.                     [4] = function()
  723.                         if pldotec.smer == 1 then
  724.                             pldotec.afaze = 7
  725.                         end
  726.                     end,
  727.                 }
  728.                 if pldotec.ocko == 0 then
  729.                     if random(100) < 10 then
  730.                         pldotec.ocko = 3
  731.                     end
  732.                 end
  733.                 if pldotec.ocko > 0 then
  734.                     pldotec.ocko = pldotec.ocko - 1
  735.                 end
  736.                 if pldotec.ocko > 0 then
  737.                     if pldotec.afaze == 0 then
  738.                         pldotec.afaze = 9
  739.                     else
  740.                         pldotec.afaze = pldotec.afaze + 6
  741.                     end
  742.                 end
  743.             end
  744.             pldotec:updateAnim()
  745.         end
  746.     end
  747.  
  748.     -- -------------------------------------------------------------
  749.     local function prog_init_levahlava()
  750.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  751.  
  752.         levahlava.kouka = random(3)
  753.         levahlava.makoukat = levahlava.kouka
  754.         levahlava.cinnost = 0
  755.  
  756.         return function()
  757.             if levahlava.kouka == 0 and pravahlava.kouka == 0 and levahlava.cinnost == 0 and levahlava.cinnost == 0 and levahlava.makoukat == 0 and pravahlava.makoukat == 0 and random(100) < 5 then
  758.                 levahlava.cinnost = 2
  759.                 pravahlava.cinnost = 2
  760.             end
  761.             if levahlava.kouka ~= levahlava.makoukat then
  762.                 if levahlava.kouka == 1 or levahlava.makoukat == 1 then
  763.                     levahlava.kouka = levahlava.makoukat
  764.                 else
  765.                     levahlava.kouka = 1
  766.                 end
  767.             end
  768.             switch(levahlava.cinnost){
  769.                 [0] = function()
  770.                     if random(1000) < 5 then
  771.                         levahlava.cinnost = 1
  772.                     elseif random(100) < 5 then
  773.                         levahlava.makoukat = random(3)
  774.                     end
  775.                     levahlava.afaze = levahlava.kouka * 2
  776.                     if levahlava.afaze > 0 then
  777.                         levahlava.afaze = levahlava.afaze + 1
  778.                     end
  779.                     if random(100) < 95 then
  780.                         levahlava.afaze = levahlava.afaze + 1
  781.                     end
  782.                 end,
  783.                 [1] = function()
  784.                     levahlava.afaze = levahlava.kouka * 2
  785.                     if levahlava.afaze > 0 then
  786.                         levahlava.afaze = levahlava.afaze + 1
  787.                     end
  788.                     if random(1000) < 5 then
  789.                         levahlava.cinnost = 0
  790.                     end
  791.                 end,
  792.                 [2] = function()
  793.                     levahlava.afaze = 2
  794.                     if random(100) < 3 then
  795.                         levahlava.cinnost = 0
  796.                         pravahlava.cinnost = 0
  797.                     end
  798.                 end,
  799.             }
  800.             levahlava:updateAnim()
  801.         end
  802.     end
  803.  
  804.     -- -------------------------------------------------------------
  805.     local function prog_init_pravahlava()
  806.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  807.  
  808.         pravahlava.kouka = random(3)
  809.         pravahlava.makoukat = pravahlava.kouka
  810.         pravahlava.cinnost = 0
  811.  
  812.         return function()
  813.             if pravahlava.kouka ~= pravahlava.makoukat then
  814.                 if pravahlava.kouka == 1 or pravahlava.makoukat == 1 then
  815.                     pravahlava.kouka = pravahlava.makoukat
  816.                 else
  817.                     pravahlava.kouka = 1
  818.                 end
  819.             end
  820.             switch(pravahlava.cinnost){
  821.                 [0] = function()
  822.                     if random(1000) < 5 then
  823.                         pravahlava.cinnost = 1
  824.                     elseif random(100) < 5 then
  825.                         pravahlava.makoukat = random(3)
  826.                     end
  827.                     pravahlava.afaze = pravahlava.kouka * 2
  828.                     if pravahlava.afaze > 0 then
  829.                         pravahlava.afaze = pravahlava.afaze + 1
  830.                     end
  831.                     if random(100) < 95 then
  832.                         pravahlava.afaze = pravahlava.afaze + 1
  833.                     end
  834.                 end,
  835.                 [1] = function()
  836.                     pravahlava.afaze = pravahlava.kouka * 2
  837.                     if pravahlava.afaze > 0 then
  838.                         pravahlava.afaze = pravahlava.afaze + 1
  839.                     end
  840.                     if random(1000) < 5 then
  841.                         pravahlava.cinnost = 0
  842.                     end
  843.                 end,
  844.                 [2] = function()
  845.                     pravahlava.afaze = 2
  846.                 end,
  847.             }
  848.             pravahlava:updateAnim()
  849.         end
  850.     end
  851.  
  852.     -- --------------------
  853.     local update_table = {}
  854.     local subinit
  855.     subinit = prog_init_room()
  856.     if subinit then
  857.         table.insert(update_table, subinit)
  858.     end
  859.     subinit = prog_init_barel()
  860.     if subinit then
  861.         table.insert(update_table, subinit)
  862.     end
  863.     subinit = prog_init_kachnicka()
  864.     if subinit then
  865.         table.insert(update_table, subinit)
  866.     end
  867.     subinit = prog_init_had()
  868.     if subinit then
  869.         table.insert(update_table, subinit)
  870.     end
  871.     subinit = prog_init_ocicko()
  872.     if subinit then
  873.         table.insert(update_table, subinit)
  874.     end
  875.     subinit = prog_init_kukajda()
  876.     if subinit then
  877.         table.insert(update_table, subinit)
  878.     end
  879.     subinit = prog_init_killer()
  880.     if subinit then
  881.         table.insert(update_table, subinit)
  882.     end
  883.     subinit = prog_init_hlubinna()
  884.     if subinit then
  885.         table.insert(update_table, subinit)
  886.     end
  887.     subinit = prog_init_krabik()
  888.     if subinit then
  889.         table.insert(update_table, subinit)
  890.     end
  891.     subinit = prog_init_baget()
  892.     if subinit then
  893.         table.insert(update_table, subinit)
  894.     end
  895.     subinit = prog_init_nozka()
  896.     if subinit then
  897.         table.insert(update_table, subinit)
  898.     end
  899.     subinit = prog_init_pldik()
  900.     if subinit then
  901.         table.insert(update_table, subinit)
  902.     end
  903.     subinit = prog_init_shark()
  904.     if subinit then
  905.         table.insert(update_table, subinit)
  906.     end
  907.     subinit = prog_init_pldotec()
  908.     if subinit then
  909.         table.insert(update_table, subinit)
  910.     end
  911.     subinit = prog_init_levahlava()
  912.     if subinit then
  913.         table.insert(update_table, subinit)
  914.     end
  915.     subinit = prog_init_pravahlava()
  916.     if subinit then
  917.         table.insert(update_table, subinit)
  918.     end
  919.     return update_table
  920. end
  921. local update_table = prog_init()
  922.  
  923.  
  924. -- -----------------------------------------------------------------
  925. -- Update
  926. -- -----------------------------------------------------------------
  927. function prog_update()
  928.     for key, subupdate in pairs(update_table) do
  929.         subupdate()
  930.     end
  931. end
  932.  
  933.